class Solution {
public:
    double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
        int m = nums1.size(), n = nums2.size(), i = 0;
        vector<int> nums(m + n);
        for(auto& e : nums1)
        {
            nums[i++] = e;
        }
        for(auto& e : nums2)
        {
            nums[i++] = e;
        }

        sort(nums.begin(), nums.end());
        int tmp = (m + n) / 2;
        return (m + n) % 2 == 0 ? (nums[tmp - 1] + nums[tmp] ) / 2.0 : (double)nums[tmp];
    }
};